package com.shiguiwu.springmybatis.spring.lifecycle.parse;

import com.shiguiwu.springmybatis.spring.autowired.B;
import com.shiguiwu.springmybatis.spring.autowired.resource.Rb;
import com.shiguiwu.springmybatis.spring.autowired.resource.Rc;
import com.shiguiwu.springmybatis.spring.lazy.A;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;

/**
 * @description: 2，注解解析类
 * @author: stone
 * @date: Created by 2021/3/23 10:16
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.spring.lifecycle.parse
 */
public class  AnnotatedParseTests {

    public static void main(String[] args) {
        //1定义一个容器，一个注册器
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();

        //2定义一个注解读取器
        AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(factory);

        //3注册到注解解析器中
        reader.register(B.class);

        System.out.println(factory.getBean("b"));
        System.out.println(factory.getBeanDefinition("b").getClass().getName());
        System.out.println("========================");


        factory.getBeansOfType(BeanPostProcessor.class).values().forEach(factory::addBeanPostProcessor); // @1

//        String[] beanDefinitionNames = factory.getBeanDefinitionNames();
//        for (String name : beanDefinitionNames) {
//            System.out.println(factory.getBean(name));
//            System.out.println("========================");
//        }
    }
}
